package com.zhenai.rocyuan.modules.worker.service.impl;

import javax.annotation.Resource;

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcOperations;
import org.springframework.stereotype.Service;

import com.zhenai.rocyuan.modules.worker.model.Worker;
import com.zhenai.rocyuan.modules.worker.service.WorkerService;

@Service("workerService")
public class WorkerServiceImpl implements WorkerService {

	@Resource
	private SimpleJdbcOperations crmBJdbc;

	private ParameterizedRowMapper<Worker> rowMapper = ParameterizedBeanPropertyRowMapper
			.newInstance(Worker.class);

	@Override
	public Worker select(Integer workerId) {
		String sql = "select w.*,o.deptName,o.storeName from Worker w left join OutFinancialContract o on w.deptId=o.deptId where workerId=?";
		try{
			return crmBJdbc.queryForObject(sql, rowMapper, workerId);
		}catch(Exception e){
			
		}
		return null;
	}

}
